# -*- coding: utf-8 -*-
# author:HHR
# time:2021/2/21:8:50
# ___msg___ = '创建年费任务'

from quote_folder.Db_connect import DB_connect


class create_big_tasK():
    def __init__(self):
        self.mysql_con = DB_connect().online_db()
        self.mysql_cur = self.mysql_con.cursor()
        self.online_con = DB_connect().online_big_data()
        self.big_cur = self.online_con.cursor()
        self.redis_con = DB_connect().patents_reids()

    def get_sqh(self):
        sql = "SELECT application_number FROM ccy_paid GROUP BY application_number"
        try:
            self.big_cur.execute(sql)
        except Exception as E:
            print("查询错误！", E)
        all_data = self.big_cur.fetchall()
        li = []
        for item in all_data:
            li.append(item[0])
        return li

    def big_task(self):
        sql = "select application_number from finals where application_number !=''"
        try:
            self.mysql_cur.execute(sql)
        except Exception as E:
            print("查询错误！", E)
        all_data = self.mysql_cur.fetchall()
        li = []
        for item in all_data:
            li.append(item[0].strip("ZL"))
        return li

    def main(self):
        li_finals = self.big_task()
        li_ccy = self.get_sqh()
        Dirt = list(set(li_ccy).difference(li_finals))    # 返回集合数据在li_cyy且不在li_finals
        print(len(Dirt))
        for sqh in Dirt:
            shen = "ZL" + sqh
            self.redis_con.sadd("不同申请号", shen)


if __name__ == '__main__':
    create_big_tasK().main()
